import sys

function swap(array, a, b)
{
	var tmp = array[a];
	array[a] = array[b];
	array[b] = tmp;
}
	
#partition array according to array[i]
function partition(array, range, pivotIndex)
{
	var left, right = range;
	var pivotValue = array[pivotIndex];
	swap(array, pivotIndex, right);
	var storeIndex = left;
	var i = left;
	while (i < right)
	{
		if (array[i] < pivotValue)
		{
			swap(array, storeIndex, i);
			storeIndex += 1;
		}
		i += 1;
	}
	swap(array, right, storeIndex);
	return storeIndex;
}

	
function qsort(array, left, right)
{
	if (right > left)
	{
		var pivotNewIndex = partition(array, (left, right), left);
		qsort(array, left, pivotNewIndex-1);
		qsort(array, pivotNewIndex+1, right);
	}
}

function sort(array, len)
{
	qsort(array, 0, len-1);
}

	
function ordered(array, len)
{
	var i = 1;
	while (i < len)
	{
		if (array[i-1]>array[i])
			return False;
		i += 1;
	}
	return True;
}


var arr = [5, 4, 2, 7, 0, 6, 1, 3, 8, 9];
var retcode = {True:0, False:1};
var succ = True;
succ = succ and not ordered(arr,10);
sort(arr,10);
succ = succ and ordered(arr,10);

sys.exit(retcode[succ]);
